﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RRTlnsotsparingResponse", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRTlnsotsparingResponse))]
    public class RRTlnsotsparingResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRRTlnsotsparingResponse clazz;
        
        public RRTlnsotsparingResponseSerializer(IRRTlnsotsparingResponse clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("pocYldPealdis");
            if (clazz.PocYldPealdis!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocYldPealdis))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocYldPealdis");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocPealdisTaotleja");
            if (clazz.PocPealdisTaotleja!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocPealdisTaotleja))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocPealdisTaotleja");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocEesnimi");
            if (clazz.PocEesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocEesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocEesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocPerenimi");
            if (clazz.PocPerenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocPerenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocPerenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocIsikuKood");
            if (clazz.PocIsikuKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocIsikuKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocIsikuKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocTelefon");
            if (clazz.PocTelefon!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocTelefon))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocTelefon");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocElukohaAadress");
            if (clazz.PocElukohaAadress!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocElukohaAadress))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocElukohaAadress");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocPealdisEsindaja");
            if (clazz.PocPealdisEsindaja!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocPealdisEsindaja))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocPealdisEsindaja");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocEsindajaEesnimi");
            if (clazz.PocEsindajaEesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocEsindajaEesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocEsindajaEesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocEsindajaPerenimi");
            if (clazz.PocEsindajaPerenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocEsindajaPerenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocEsindajaPerenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocEsindajaIsikukood");
            if (clazz.PocEsindajaIsikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocEsindajaIsikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocEsindajaIsikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocEsindajaTelefon");
            if (clazz.PocEsindajaTelefon!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocEsindajaTelefon))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocEsindajaTelefon");
            }
            Writer.WriteEndElement();
            if (clazz.PocAvalduseTekst!=null) {
                Writer.WriteStartElement("pocAvalduseTekst");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocAvalduseTekst))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("pocSaabKuhu");
            if (clazz.PocSaabKuhu!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocSaabKuhu))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocSaabKuhu");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocSaajaKonto");
            if (clazz.PocSaajaKonto!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocSaajaKonto))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocSaajaKonto");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocSaajaAadress");
            if (clazz.PocSaajaAadress!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocSaajaAadress))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocSaajaAadress");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocSaajaSihtnumber");
            if (clazz.PocSaajaSihtnumber!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocSaajaSihtnumber))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocSaajaSihtnumber");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocSalvestaNuppKuva");
            if (clazz.PocSalvestaNuppKuva!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocSalvestaNuppKuva))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocSalvestaNuppKuva");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocTeadeKodanikule");
            if (clazz.PocTeadeKodanikule!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocTeadeKodanikule))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocTeadeKodanikule");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="pocYldPealdis") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocYldPealdis");
                }
                clazz.PocYldPealdis = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocYldPealdis")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocYldPealdis", Reader.LocalName);
            }
            if (Reader.LocalName=="pocPealdisTaotleja") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocPealdisTaotleja");
                }
                clazz.PocPealdisTaotleja = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocPealdisTaotleja")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocPealdisTaotleja", Reader.LocalName);
            }
            if (Reader.LocalName=="pocEesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocEesnimi");
                }
                clazz.PocEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocEesnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocEesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="pocPerenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocPerenimi");
                }
                clazz.PocPerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocPerenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocPerenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="pocIsikuKood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocIsikuKood");
                }
                clazz.PocIsikuKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocIsikuKood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocIsikuKood", Reader.LocalName);
            }
            if (Reader.LocalName=="pocTelefon") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocTelefon");
                }
                clazz.PocTelefon = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocTelefon")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocTelefon", Reader.LocalName);
            }
            if (Reader.LocalName=="pocElukohaAadress") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocElukohaAadress");
                }
                clazz.PocElukohaAadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocElukohaAadress")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocElukohaAadress", Reader.LocalName);
            }
            if (Reader.LocalName=="pocPealdisEsindaja") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocPealdisEsindaja");
                }
                clazz.PocPealdisEsindaja = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocPealdisEsindaja")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocPealdisEsindaja", Reader.LocalName);
            }
            if (Reader.LocalName=="pocEsindajaEesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocEsindajaEesnimi");
                }
                clazz.PocEsindajaEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocEsindajaEesnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocEsindajaEesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="pocEsindajaPerenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocEsindajaPerenimi");
                }
                clazz.PocEsindajaPerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocEsindajaPerenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocEsindajaPerenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="pocEsindajaIsikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocEsindajaIsikukood");
                }
                clazz.PocEsindajaIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocEsindajaIsikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocEsindajaIsikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="pocEsindajaTelefon") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocEsindajaTelefon");
                }
                clazz.PocEsindajaTelefon = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocEsindajaTelefon")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocEsindajaTelefon", Reader.LocalName);
            }
            if (Reader.LocalName=="pocAvalduseTekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocAvalduseTekst");
                }
                clazz.PocAvalduseTekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocAvalduseTekst")).Value;
            }
            if (Reader.LocalName=="pocSaabKuhu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocSaabKuhu");
                }
                clazz.PocSaabKuhu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocSaabKuhu")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocSaabKuhu", Reader.LocalName);
            }
            if (Reader.LocalName=="pocSaajaKonto") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocSaajaKonto");
                }
                clazz.PocSaajaKonto = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocSaajaKonto")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocSaajaKonto", Reader.LocalName);
            }
            if (Reader.LocalName=="pocSaajaAadress") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocSaajaAadress");
                }
                clazz.PocSaajaAadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocSaajaAadress")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocSaajaAadress", Reader.LocalName);
            }
            if (Reader.LocalName=="pocSaajaSihtnumber") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocSaajaSihtnumber");
                }
                clazz.PocSaajaSihtnumber = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocSaajaSihtnumber")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocSaajaSihtnumber", Reader.LocalName);
            }
            if (Reader.LocalName=="pocSalvestaNuppKuva") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocSalvestaNuppKuva");
                }
                clazz.PocSalvestaNuppKuva = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocSalvestaNuppKuva")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocSalvestaNuppKuva", Reader.LocalName);
            }
            if (Reader.LocalName=="pocTeadeKodanikule") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingResponse>pocTeadeKodanikule");
                }
                clazz.PocTeadeKodanikule = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocTeadeKodanikule")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingResponse>pocTeadeKodanikule", Reader.LocalName);
            }
        }
    }
}
